package com.henry.config;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Liu Hanlin
 * @create 2025-11-08 23:51
 */
@Data
@ConfigurationProperties(prefix = "rocketmq")
public class CustomerRocketMQProperties {

    private String nameServer;
    private String accessChannel;
    private Producer producer;
    private PullConsumer pullConsumer = new PullConsumer();
    private PushConsumer consumer = new PushConsumer();

    /** 生产者组统一前缀 */
    private String producerGroupPrefix = "DEFAULT_PRODUCT_GROUP";

    /** 消费者组统一前缀 */
    private String consumerGroupPrefix = "DEFAULT_CONSUMER_GROUP";

    public CustomerRocketMQProperties() {
    }

    @Data
    @NoArgsConstructor
    public static class PushConsumer extends PullConsumer {
        private Map<String, Map<String, Boolean>> listeners = new HashMap();

    }

    @Data
    @NoArgsConstructor
    public static class PullConsumer {
        private String group;
        private String namespace;
        private String namespaceV2;
        private String topic;
        private String messageModel = "CLUSTERING";
        private String selectorType = "TAG";
        private String selectorExpression = "*";
        private String accessKey;
        private String secretKey;
        private int pullBatchSize = 10;
        private boolean enableMsgTrace = false;
        private String customizedTraceTopic = "RMQ_SYS_TRACE_TOPIC";
        private boolean tlsEnable = false;
        private String instanceName = "DEFAULT";
    }

    @Data
    @NoArgsConstructor
    public static class Producer {
        private String group;
        private String namespace;
        private String namespaceV2;
        private int sendMessageTimeout = 3000;
        private int compressMessageBodyThreshold = 4096;
        private int retryTimesWhenSendFailed = 2;
        private int retryTimesWhenSendAsyncFailed = 2;
        private boolean retryNextServer = false;
        private int maxMessageSize = 4194304;
        private String accessKey;
        private String secretKey;
        private boolean enableMsgTrace = false;
        private String customizedTraceTopic = "RMQ_SYS_TRACE_TOPIC";
        private boolean tlsEnable = false;
        private String instanceName = "DEFAULT";

    }

}
